home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 23 / AACD 23.iso / AACD / Programming / tek / array / stringdup.c < prev    next >
C/C++ Source or Header  |  2001-05-12  |  446b  |  33 lines

  1.  
  2. #include "tek/array.h"
  3.  
  4. /* 
  5. **    TEKlib
  6. **    (C) 2001 TEK neoscientists
  7. **    all rights reserved.
  8. **
  9. **    TSTRPTR TStringDup(TSTRPTR s)
  10. **
  11. **    create duplicate from a dynamic string.
  12. **
  13. */
  14.  
  15. TSTRPTR TStringDup(TSTRPTR s)
  16. {
  17.     if (s)
  18.     {
  19.         TARRAY *a = ((TARRAY *) s) - 1;
  20.         if (a->valid)
  21.         {
  22.             TSTRPTR array = TCreateArray(a->mmu, 1, a->len, TNULL);
  23.             if (array && a->len)
  24.             {
  25.                 TMemCopy(s, array, a->len);
  26.             }
  27.  
  28.             return array;
  29.         }
  30.     }
  31.     return TNULL;
  32. }
  33.